package io.hots.controller;

import io.hots.controller.request.ScanCodeRequest;
import io.hots.service.ScanCodeService;
import io.hots.util.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yueshibin@cetcbigdata.com
 * @date 2022/6/8 8:25 下午
 */


@Api("扫码服务")
@RestController
@RequestMapping("/api/scan/v1")
public class ScanCodeController {

    @Autowired
    ScanCodeService scanCodeService;

    /**
     *  用户注册
     * @param scanCodeRequest
     * @return
     */
    @ApiOperation("扫码")
    @PostMapping("code")
    public ResultData register(@ApiParam("扫码对象") @RequestBody ScanCodeRequest scanCodeRequest){

        scanCodeService.scanCodeSave(scanCodeRequest);
        return ResultData.buildSuccess();
    }

    /**
     * 查询用户扫码过的场所
     * @return
     */
    @ApiOperation("查询用户扫码过的场所")
    @GetMapping("user/venue/list")
    public ResultData queryUserVenueById(@RequestParam("user_id") String userId){

        ResultData resultData = scanCodeService.queryUserVenueById(userId);

        return resultData;
    }


    /**
     * 查询场所访问的用户
     * @return
     */
    @ApiOperation("查询场所访问的用户")
    @GetMapping("venue/user/list")
    public ResultData queryVenueUserById(@RequestParam("venue_id") String venueId){

        ResultData resultData = scanCodeService.queryVenueUserById(venueId);

        return resultData;
    }

}
